module.exports = {
	
	// #ifdef MP-WEIXIN
	onLoad(options) {
		if(options.invitecode) {
			uni.setStorageSync('invitecode', options.invitecode);
		}
	},
	onShareAppMessage(res) {
		let pages = getCurrentPages();
		let route = pages[pages.length - 1].$page.fullPath;
		let path = ''
		if (uni.getStorageSync('token') && uni.getStorageSync('userinfo')) {
			if (route.indexOf('?') == -1) {
				path = route + '?invitecode='+ uni.getStorageSync('userinfo').invitecode
			} else {
				path = route + '&invitecode='+ uni.getStorageSync('userinfo').invitecode
			}
		} else {
			path = route
		}
		console.log(path)
		return {
			title: '半柿',
			path: path
		}
	},
	onShareTimeline(res) {
		let pages = getCurrentPages();
		let route = pages[pages.length - 1].$page.fullPath;
		let path = ''
		if (uni.getStorageSync('token') && uni.getStorageSync('userinfo')) {
			if (route.indexOf('?') == -1) {
				path = route + '?invitecode='+ uni.getStorageSync('userinfo').invitecode
			} else {
				path = route + '&invitecode='+ uni.getStorageSync('userinfo').invitecode
			}
		} else {
			path = route
		}
		return {
			title: '半柿',
			path: path
		}
	}
	// #endif
}